package contegor.scire.core.modifications;

import contegor.scire.core.Container;
import contegor.scire.core.DuplicateElementException;
import contegor.scire.core.Id;
import contegor.scire.core.IdFragment;
import contegor.scire.core.Modifiable;
import contegor.scire.core.Primitive;
import contegor.scire.core.Version;

/**
 * {@link Modification} used to notify a {@link Modifiable} that it must create inside itself a {@link Primitive}.
 *
 * @version $Revision: 1.3 $
 * @author  Héctor Cirbián Pousa ($Author: hector $)
 */
@Version("$Id: CreatePrimitive.java,v 1.3 2010-02-01 10:55:40 hector Exp $")
public class CreatePrimitive extends BaseCreateConcept<Primitive> {
  private static final long serialVersionUID = 2886787493989581794L;

  protected Object value;

  public CreatePrimitive(Id targetContainerId, IdFragment conceptId, Object value) {
    super(targetContainerId, conceptId);
    this.value = value;
  }

  public void process(Container modifiable) throws DuplicateElementException {
    super.isValidForThisContainer(modifiable);
    this.result = ((Modifiable)modifiable).createPrimitive(relatedTime, this.taskId.getTransactionId(), conceptId, value);
    returnPoint.manage(this.taskId, this.result);
  }
}
